package com.kefu.robot.vo;

import java.util.Set;

import javax.validation.constraints.Size;

import org.apache.commons.lang3.StringUtils;

import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import com.kefu.robot.model.RobotDoc;
import com.kefu.robot.model.RobotDocLink;
import com.kefu.robot.model.RobotDocQuestion;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author
 * @date 2021/04/05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "知识词条")
public class RobotDocInsertVo extends AbstractInsertVo<RobotDoc> {
    @ApiModelProperty(name = "robotNo", value = "机器人")
    private Integer robotNo;
    @Size(max = 32)
    @ApiModelProperty(name = "docTypeId", value = "词条分类")
    private String docTypeId;
    @ApiModelProperty(name = "docPattern", value = "模式：0单轮问题，1多轮问题")
    private Integer docPattern;
    @ApiModelProperty(name = "docAnswer", value = "答案")
    private String docAnswer;
    @ApiModelProperty(name = "docQuestion", value = "标准问题")
    private String docQuestion;
    @ApiModelProperty(name = "timeMode", value = "有效期：0永久生效，1有截止时间")
    private Integer timeMode;
    @ApiModelProperty(name = "startTime", value = "开始时间")
    private Long startTime;
    @ApiModelProperty(name = "endTime", value = "结束时间")
    private Long endTime;
    @ApiModelProperty(name = "similarQuestions", value = "相似问题")
    private Set<RobotDocQuestion> similarQuestions;
    @ApiModelProperty(name = "linkQuestions", value = "关联问题")
    private Set<RobotDocLink> linkQuestions;
    @ApiModelProperty(hidden = true)
    private Integer docStatus = 1;
    @ApiModelProperty(hidden = true)
    private String docId;
    @ApiModelProperty(value = "是否挂机：0否，1是")
    private Integer hangupMode;
    @ApiModelProperty(value = "是否跳转：0否，1是")
    private Integer nextMode;
    
    @ApiModelProperty(value = "3富文本，4文件，5音频，6视频，7商品卡片，8订单卡片,9工单卡片")
    private Integer msgType=3;

    @Override
    public RobotDoc convert() {
        RobotDoc info = BeanUtil.toBean(this, RobotDoc.class);
        KefuContext context = KefuContext.getKefuContext();
        if(StringUtils.isBlank(docId)) {
        	info.setDocId(IdUtil.simpleUUID());
        }else {
        	info.setDocId(docId);
        }
        info.setTenantId(context.getTenantId());
        info.setCreateUser(context.getUserId());
        info.setCreateTime(context.getNow());
        info.setUpdateUser(context.getUserId());
        info.setUpdateTime(context.getNow());
        return info;
    }

}
